package com.example.sellqq.vo;

import com.example.sellqq.constant.ResponseConstant;

/**
 * @Author: thekernel
 * @Date: 2020/4/19 23:54
 * @Version: 1.0
 * @Description: API Response
 */
public class ResponseVO {

    private Integer code;
    private String msg;
    private Object data;

    public static ResponseVO build() {
        return new ResponseVO();
    }

    public static ResponseVO success(String msg) {
        return new ResponseVO(ResponseConstant.SUCCESS, msg, null);
    }

    public static ResponseVO success(String msg, Object data) {
        return new ResponseVO(ResponseConstant.SUCCESS, msg, data);
    }

    public static ResponseVO error(String msg) {
        return new ResponseVO(ResponseConstant.FAIL, msg, null);
    }

    public static ResponseVO error(String msg, Object data) {
        return new ResponseVO(ResponseConstant.FAIL, msg, data);
    }

    private ResponseVO() {

    }

    private ResponseVO(ResponseConstant responseCode, String msg, Object data) {
        this.code = responseCode.code;
        this.msg = msg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
